/*
使用proto对象定义对象方法时，箭头函数也不能很好地工作：
*/

class User {
    constructor(name) {
        this.name = name;
    }
}

User.prototype.swim = () => {
    console.log("", this)
    console.log(this.name + ' is swimming');
}
User.prototype.swimEs5 = function() {
    console.log(this.name + ' is swimming');
}
var user = new User('Jack');
user.swim();   //undefined is swimming
user.swimEs5();  //Jack is swimming

